package com.wicket.okrapp.web.contorller;

import com.wicket.okrapp.biz.service.DualHighTaskRelationshipService;
import com.wicket.okrapp.common.ro.OkrResult;
import com.wicket.okrapp.dal.po.mbg.OmsDualHighTaskRelationship;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @author CHS
 * @since 2025-10-02
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/app/dual/high/task/relationship/")
public class DualHighTaskRelationshipController {

    @Autowired
    DualHighTaskRelationshipService service;

    /**
     * 新增-双高标准框架数据
     */
    @PostMapping("add")
    public OkrResult<String> add(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(service.addDualHighTaskRelationship(obj));
    }

    /**
     * 修改-双高标准框架数据
     */
    @PostMapping("update")
    public OkrResult<Boolean> update(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(service.updateDualHighTaskRelationship(obj));
    }

    /**
     * 删除-双高标准框架数据
     */
    @PostMapping("delete")
    public OkrResult<Boolean> delete(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(service.deleteDualHighTaskRelationship(obj.getIndicatorId()));
    }

    /**
     * 列表-双高标准框架数据
     */
    @PostMapping("list")
    public OkrResult<ArrayList<OmsDualHighTaskRelationship>> list(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(new ArrayList<>(service.queryDualHighTaskRelationshipList(obj)));
    }

    /**
     * 详情-双高标准框架数据
     */
    @PostMapping("detail")
    public OkrResult<OmsDualHighTaskRelationship> detail(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(service.queryDualHighTaskRelationshipDetail(obj));
    }

    /**
     * 维护-双高标准框架数据
     */
    @PostMapping("change")
    public OkrResult<Boolean> change(@RequestBody @Validated OmsDualHighTaskRelationship obj){
        return OkrResult.success(service.changeDualHighTaskRelationship(obj));
    }

}
